package com.hl.sfzy.controller;

import com.hl.sfzy.entity.TeacherLevel;
import com.hl.sfzy.entity.Good;
import com.hl.sfzy.entity.Appointment;
import com.hl.sfzy.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;

    @GetMapping("/teacherLevels")
    public ResponseEntity<List<TeacherLevel>> getTeacherLevels() {
        List<TeacherLevel> levels = appointmentService.getTeacherLevels();
        return ResponseEntity.ok(levels);
    }

    @GetMapping("/goods")
    public ResponseEntity<List<Good>> getGoods() {
        List<Good> goods = appointmentService.getGoods();
        return ResponseEntity.ok(goods);
    }

    @PostMapping("/appointments/create")
    public ResponseEntity<Map<String, Boolean>> createAppointment(@RequestBody Appointment appointment) {
        boolean success = appointmentService.createAppointment(appointment);
        Map<String, Boolean> response = new HashMap<>();
        response.put("success", success);
        return ResponseEntity.ok(response);
    }
}